package com.xjlsoft.weather.service.impl;


import com.xjlsoft.weather.dto.ExportDto;
import com.xjlsoft.weather.dto.GroundDataListDto;
import com.xjlsoft.weather.dto.WeatherDataQueryDto;
import com.xjlsoft.weather.entity.GroundData;
import com.xjlsoft.weather.entity.GroundDataExcelDto;
import com.xjlsoft.weather.mapper.GroundDataExcelDtoMapper;
import com.xjlsoft.weather.mapper.GroundDataMapper;
import com.xjlsoft.weather.service.GroundDataExcelDtoService;
import com.xjlsoft.weather.service.GroundDataService;
import com.xjlsoft.weather.util.WeatherDataUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 地面数据 服务实现类
 * </p>
 *
 * @author zhangbanglong
 * @since 2020-07-22
 */
@Service
public class GroundDataExcelDtoServiceImpl extends ServiceImpl<GroundDataExcelDtoMapper, GroundDataExcelDto> implements GroundDataExcelDtoService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(GroundDataExcelDtoServiceImpl.class);

	@Value("${fileSaveDirPrefix}")
	private String fileSaveDirPrefix;// 文件存储根路径
	
	
	@Autowired
	private GroundDataExcelDtoMapper groundDataExcelDtoMapper;


	@Override
	public List<GroundDataExcelDto> getList(ExportDto exportDto) throws Exception {
		QueryWrapper<GroundDataExcelDto> query = Wrappers.query();
		//query.select(weatherDataDto.getSelectFilds());
		/*query.select("ground_data_id","data_query_id","create_time","data_time","station_name","province","city",
				    "cnty","town","year","mon","day","hour","lat","lon","alti","prs_sensor_alti","win_s_sensor_heigh","prs",
				     "prs_sea","tem","rhu","pre","gst");*/
        //拼接条件
        /*query.eq(StringUtils.isNotBlank(weatherDataDto.getMaleFlag()), "male_flag", personQueryParam.getMaleFlag())
                .eq(ObjectUtil.isNotNull(personQueryParam.getNationType()), "nation_type", personQueryParam.getNationType())
                .eq(ObjectUtil.isNotNull(personQueryParam.getEducationType()), "education_type", personQueryParam.getEducationType())
                .eq(ObjectUtil.isNotNull(personQueryParam.getPoliticsType()), "politics_type", personQueryParam.getPoliticsType()));*/
    
		if(StringUtils.isNotBlank(exportDto.getDateStart())){
			Timestamp timestart=WeatherDataUtil.strToTimestamp(exportDto.getDateStart());
			query.ge("data_time", timestart);
		}
		if(StringUtils.isNotBlank(exportDto.getDateEnd())){
			Timestamp timeend=WeatherDataUtil.strToTimestamp(exportDto.getDateEnd());
			query.le("data_time", timeend);
		}
       
        List<GroundDataExcelDto> list =groundDataExcelDtoMapper.selectList(query);
		return list;
	}

	

}
